//此文件是用来统一发送请求的，以便于将来统一维护或是管理 比如更改接口
//1、引入ajax
import ajax from './ajax';
import mockAjax from './mockAjax';
//2、发送请求 获取三级分类列表数据
export const reqCategoryListData = () =>
  ajax.get('/product/getBaseCategoryList');

//3、发送请求，获取mock数据
//获取轮播图数据
export const reqBannerListDate = () => mockAjax.get('/banner');

//4、获取楼层数据
export const reqGetFloorsListData = () => mockAjax.get('/floor');

//5、获取搜索数据，这个不是List 因为不是数组，是一个对象
export const reqSearchGoodsInfoData = (searchParams) =>
  ajax.post('/list', searchParams);

//6、获取商品详细数据
export const reqGetGoodDetailInfoData = (id) => ajax.get(`/item/${id}`);

//7、添加购物车
export const reqAddOrUpdateCart = (skuId, skuNum) =>
  ajax.post(`/cart/addToCart/${skuId}/${skuNum}`);

//8、发送请求获取购物车中的商品数据
export const reqShopCartListData = () => ajax.get('/cart/cartList');

//9、更新购物车中数据的选中状态
export const reqChangeShopCartInfoState = (skuID, isChecked) =>
  ajax.get(`/cart/checkCart/${skuID}/${isChecked}`);

//10、删除一件购物车的商品
export const reqDelOnShopCartInfo = (skuId) =>
  ajax.delete(`/cart/deleteCart/${skuId}`);

//11、 批量删除商品
export const reqDelSelectedCartInfo = (selectedObj) =>
  ajax.delete(`/cart/batchDeleteCart`, { data: selectedObj });

//12、获取手机验证码
export const reqGetVerifyCode = (phone) =>
  ajax.get(`/user/passport/sendCode/${phone}`);

//13、注册账号
export const reqRegister = (user) => ajax.post('/user/passport/register', user);

// 14. 实现登陆
export const reqUserLogin = (user) => ajax.post('/user/passport/login', user);

// 15. 登出
export const reqUserLogout = () => ajax.get('/user/passport/logout');

// 16. 获取邮寄地址
export const reqGetUserAddressList = () =>
  ajax.get('/user/userAddress/auth/findUserAddressList');

// 17. 获取订单交易页数据
export const reqTradeInfoData = () => ajax.get('/order/auth/trade');
